﻿Imports System.Runtime.InteropServices

Friend NotInheritable Class NativeMethods

    <DllImport("user32")> _
    Public Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As IntPtr
    End Function

    <DllImport("kernel32")> _
    Public Shared Function GetCurrentThreadId() As IntPtr
    End Function

    <DllImport("user32")> _
    Public Shared Function SetWindowsHookEx(ByVal idHook As Integer, ByVal lpfn As HOOKPROC, ByVal hInstance As IntPtr, ByVal threadId As IntPtr) As IntPtr
    End Function

    <DllImport("user32")> _
    Public Shared Function UnhookWindowsHookEx(ByVal hHook As IntPtr) As Boolean
    End Function

    <DllImport("user32")> _
    Public Shared Function CallNextHookEx(ByVal hHook As IntPtr, ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    End Function

    <DllImport("user32")> _
    Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
    End Function

    <DllImport("user32")> _
    Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef lpRect As RECT) As Boolean
    End Function

    <DllImport("user32")> _
    Friend Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Integer
    End Function

    <DllImport("user32")> _
    Friend Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As Boolean
    End Function

    Friend Const SW_SHOWNORMAL As Integer = 1

    Public Delegate Function HOOKPROC(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr


    <StructLayout(LayoutKind.Sequential, Pack:=4)> _
    Public Structure RECT

        Public Left As Integer
        Public Top As Integer
        Public Right As Integer
        Public Bottom As Integer

        Public ReadOnly Property Width() As Integer
            Get
                Return Me.Right - Me.Left
            End Get
        End Property

        Public ReadOnly Property Height() As Integer
            Get
                Return Me.Bottom - Me.Top
            End Get
        End Property

        Public Function ToRectangle() As System.Windows.Rect
            Return New System.Windows.Rect(Me.Left, Me.Top, Me.Width, Me.Height)
        End Function

    End Structure

    Public Const GWL_HINSTANCE As Integer = -6
    Public Const WH_CBT As Integer = 5
    Public Const HCBT_ACTIVATE As Integer = 5
    Public Const SWP_NOSIZE As Integer = &H1
    Public Const SWP_NOZORDER As Integer = &H4
    Public Const SWP_NOACTIVATE As Integer = &H10

    <DllImport("winmm.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
    Public Shared Function mciSendString( _
        ByVal command As String, _
        ByVal buffer As System.Text.StringBuilder, _
        ByVal bufferSize As IntPtr, ByVal hwndCallback As IntPtr) As Integer
    End Function


End Class
